package com.teamF.bridge.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class FormatTimeEight {

    public static String formatTimeEight(String time) throws Exception {
        Date d = null;
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        d = sd.parse(time);
        long rightTime = (long) (d.getTime() + 8 * 60 * 60 * 1000); //把当前得到的时间用date.getTime()的方法写成时间戳的形式，再加上8小时对应的毫秒数
        String newtime = sd.format(rightTime);//把得到的新的时间戳再次格式化成时间的格式
        return newtime;
    }

    //测试类
    public static void main(String[] args){
        try {
            System.out.println(formatTimeEight("2019-02-22 06:08:10"));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
